HVM: Do not watch control/shutdown to force domain shutdowns when PV
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 12 Apr 2007 11:12:56 +0000 (12:12 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 12 Apr 2007 11:12:56 +0000 (12:12 +0100)
drivers are not present. The feature-foo mechanism does not actually
work after save/restore since the fields do not get rewritten. And it
doesn't work when we actually need the guest to be shutdown through
Xen (e.g., on suspend). Since we can quite reasonably assume that the
only entity to screw with control/shutdown is xend, and since the one
place that does that now explicitly handles unenlightened HVM guests,
we can simply strip all this stuff out.

This has the nice benefit of making HVM save/restore with PV drivers
much more reliable.

Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/core/reboot.c
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/image.py

index cb95ac9326f3cc864c1191c325d426889a5a6cd0..ee6625adc6ba26c49768146046d4cecdbf20c6c3 100644 (file)
@@ -118,6 +118,7 @@ static void shutdown_handler(struct xenbus_watch *watch,
        err = xenbus_transaction_start(&xbt);
        if (err)
                return;
+
        str = (char *)xenbus_read(xbt, "control", "shutdown", NULL);
        /* Ignore read errors and empty reads. */
        if (XENBUS_IS_ERR_READ(str)) {
@@ -206,14 +207,12 @@ static int setup_shutdown_watcher(void)
                printk(KERN_ERR "Failed to set shutdown watcher\n");
                return err;
        }
-       xenbus_write(XBT_NIL, "control", "feature-reboot", "1");
 
        err = register_xenbus_watch(&sysrq_watch);
        if (err) {
                printk(KERN_ERR "Failed to set sysrq watcher\n");
                return err;
        }
-       xenbus_write(XBT_NIL, "control", "feature-sysrq", "1");
 
        return 0;
 }
index 9083e90e7779bc9479f7d10c53f97af67746ecbb..1ccf7d4f2bf789dfd742ba1cbc9536b7fc0b6c7c 100644 (file)
@@ -1601,7 +1601,6 @@ class XendDomainInfo:
             self.image = image.create(self, self.info)
             if self.image:
                 self.image.createDeviceModel(True)
-                self.image.register_shutdown_watch()
         self._storeDomDetails()
         self._registerWatches()
         self.refreshShutdown()
index ecdea40074599c41c59d85923650c14f7f5f7f9b..8f119b3ae10cac4fe0f579489521f27a45ef2eca 100644 (file)
@@ -284,9 +284,6 @@ class HVMImageHandler(ImageHandler):
         log.debug("acpi           = %d", self.acpi)
         log.debug("apic           = %d", self.apic)
 
-        self.register_shutdown_watch()
-        self.register_reboot_feature_watch()
-
         return xc.hvm_build(domid          = self.vm.getDomid(),
                             image          = self.kernel,
                             store_evtchn   = store_evtchn,
@@ -448,13 +445,9 @@ class HVMImageHandler(ImageHandler):
         log.info("device model pid: %d", self.pid)
 
     def recreate(self):
-        self.register_shutdown_watch()
-        self.register_reboot_feature_watch()
         self.pid = self.vm.gatherDom(('image/device-model-pid', int))
 
     def destroy(self, suspend = False):
-        self.unregister_shutdown_watch()
-        self.unregister_reboot_feature_watch();
         if self.pid:
             try:
                 sig = signal.SIGKILL
@@ -473,74 +466,6 @@ class HVMImageHandler(ImageHandler):
                 pass
             self.pid = None
 
-    def register_shutdown_watch(self):
-        """ add xen store watch on control/shutdown """
-        self.shutdownWatch = xswatch(self.vm.dompath + "/control/shutdown",
-                                     self.hvm_shutdown)
-        log.debug("hvm shutdown watch registered")
-
-    def unregister_shutdown_watch(self):
-        """Remove the watch on the control/shutdown, if any. Nothrow
-        guarantee."""
-
-        try:
-            if self.shutdownWatch:
-                self.shutdownWatch.unwatch()
-        except:
-            log.exception("Unwatching hvm shutdown watch failed.")
-        self.shutdownWatch = None
-        log.debug("hvm shutdown watch unregistered")
-
-    def hvm_shutdown(self, _):
-        """ watch call back on node control/shutdown,
-            if node changed, this function will be called
-        """
-        xd = xen.xend.XendDomain.instance()
-        try:
-            vm = xd.domain_lookup( self.vm.getDomid() )
-        except XendError:
-            # domain isn't registered, no need to clean it up.
-            return False
-
-        reason = vm.getShutdownReason()
-        log.debug("hvm_shutdown fired, shutdown reason=%s", reason)
-        if reason in REVERSE_DOMAIN_SHUTDOWN_REASONS:
-            vm.info['shutdown'] = 1
-            vm.info['shutdown_reason'] = \
-                REVERSE_DOMAIN_SHUTDOWN_REASONS[reason]
-            vm.refreshShutdown(vm.info)
-
-        return True # Keep watching
-
-    def register_reboot_feature_watch(self):
-        """ add xen store watch on control/feature-reboot """
-        self.rebootFeatureWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \
-                                         self.hvm_reboot_feature)
-        log.debug("hvm reboot feature watch registered")
-
-    def unregister_reboot_feature_watch(self):
-        """Remove the watch on the control/feature-reboot, if any. Nothrow
-        guarantee."""
-
-        try:
-            if self.rebootFeatureWatch:
-                self.rebootFeatureWatch.unwatch()
-        except:
-            log.exception("Unwatching hvm reboot feature watch failed.")
-        self.rebootFeatureWatch = None
-        log.debug("hvm reboot feature watch unregistered")
-
-    def hvm_reboot_feature(self, _):
-        """ watch call back on node control/feature-reboot,
-            if node changed, this function will be called
-        """
-        status = self.vm.readDom('control/feature-reboot')
-        log.debug("hvm_reboot_feature fired, module status=%s", status)
-        if status == '1':
-            self.unregister_shutdown_watch()
-
-        return True # Keep watching
-
 
 class IA64_HVM_ImageHandler(HVMImageHandler):